package edu.govschool2010.screens;

import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.widget.CompoundButton;
import android.widget.TimePicker;
import android.widget.CheckBox;

public class TimeScreen extends Activity {
    /** Called when the activity is first created. */
    
    int startHour, startMin, endHour, endMin;
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main); 
        
        final TimePicker start = (TimePicker) findViewById(R.id.StartTimePicker);
        final TimePicker end = (TimePicker) findViewById(R.id.EndTimePicker);
        start.setCurrentHour(0);
        start.setCurrentMinute(0);
        end.setCurrentHour(12);
        end.setCurrentMinute(0);
        
        start.setOnTimeChangedListener(new TimePicker.OnTimeChangedListener() {
			public void onTimeChanged(TimePicker view, int hourOfDay, int minute) {
				startHour = hourOfDay;
				startMin = minute;
				Log.i("onTimeChanged", "startHour = " + startHour + ", startMin = " + startMin);
			}
		});
        end.setOnTimeChangedListener(new TimePicker.OnTimeChangedListener() {
			public void onTimeChanged(TimePicker view, int hourOfDay, int minute) {
				endHour = hourOfDay;
				endMin = minute;
				Log.i("onTimeChanged", "start time = " + startHour + ":" + startMin +
						", endTime = " + endHour + ":" + endMin);
			}
		});
        
        CheckBox all = (CheckBox) findViewById(R.id.AllDayCheckBox);
        all.setOnCheckedChangeListener(new CheckBox.OnCheckedChangeListener() {
        	public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
        		if (isChecked) {
                	start.setCurrentHour(0);
                	start.setCurrentMinute(0);
                	end.setCurrentHour(12);
                	end.setCurrentMinute(0);
                }
        	}
        });
        
    }
}